package io.lkt.modules.sys.service.impl;

import com.google.common.collect.Maps;
import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import io.lkt.modules.sys.dao.HeadlineTitleInfoDao;
import io.lkt.modules.sys.entity.BBrandInfoEntity;
import io.lkt.modules.sys.entity.HeadlineTitleInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;

import io.lkt.modules.sys.dao.BArticleTypeInfoDao;
import io.lkt.modules.sys.entity.BArticleTypeInfoEntity;
import io.lkt.modules.sys.service.BArticleTypeInfoService;


@Service("bArticleTypeInfoService")
public class BArticleTypeInfoServiceImpl extends ServiceImpl<BArticleTypeInfoDao, BArticleTypeInfoEntity> implements BArticleTypeInfoService {
    @Autowired
    BArticleTypeInfoDao typeInfoDao;

    @Autowired
    HeadlineTitleInfoDao headlineTitleInfoDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BArticleTypeInfoEntity> page = this.page(
                new Query<BArticleTypeInfoEntity>().getPage(params),
                new QueryWrapper<BArticleTypeInfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<BArticleTypeInfoEntity> queryAll() {
        return typeInfoDao.queryAll();
    }

    @Override
    public BArticleTypeInfoEntity queryByName(String articleTypeName) {
        return typeInfoDao.queryByName(articleTypeName);
    }

    @Override
    public List<Integer> queryByNameLike(String articleTypeName) {
        return typeInfoDao.queryByNameLike(articleTypeName);
    }

    @Override
    public String queryById(Integer id) {
        return typeInfoDao.queryById(id);
    }

    @Override
    public Integer queryByStr(String articleTypeName) {
        return typeInfoDao.queryByStr(articleTypeName);
    }

    @Override
    @DataSource("master")
    public BArticleTypeInfoEntity getById(Serializable id){
        return this.baseMapper.selectById(id);
    }

    @Override
    public  List<HeadlineTitleInfo> HeadlineTitle() {

               List<HeadlineTitleInfo> headlineTitleInfos = this.headlineTitleInfoDao.selectTitleInfoByTitle();

        return headlineTitleInfos;
    }

}
